// SPDX-FileCopyrightText: 2024 KylinSoft Co., Ltd.
//
// SPDX-License-Identifier: GPL-1.0-or-later

#include "qwaylandprimaryoutput.h"

#include "qwaylanddisplay_p.h"
#include "qwaylandscreen_p.h"

#include <QtGui/qpa/qwindowsysteminterface.h>

#include <QScreen>

QT_BEGIN_NAMESPACE

namespace QtWaylandClient
{

QWaylandPrimaryOutputV1::QWaylandPrimaryOutputV1(QWaylandDisplay *display, uint id, uint version)
    : QtWayland::kde_primary_output_v1(display->wl_registry(), id, qMin(version, uint(1)))
    , m_display(display)
{
}

void QWaylandPrimaryOutputV1::kde_primary_output_v1_primary_output(const QString &output_name)
{
    const auto screens = m_display->screens();
    for (auto *screen : screens) {
        if (screen->name() == output_name) {
            QWindowSystemInterface::handlePrimaryScreenChanged(screen);
            break;
        }
    }
}
} // namespace QtWaylandClient

QT_END_NAMESPACE
